package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

@Entity
public class User implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	private String login;
	private String nom;
	private String email;

	private String password;
	@ManyToOne
	@JoinColumn(name = "id_role")
	private Role role;
	@ManyToMany(mappedBy = "users")
	private List<Site> sites = new ArrayList<Site>();

	public User() {
		super();
	}

	public User(String nom, String email, String login, String password) {
		super();
		this.nom = nom;
		this.email = email;
		this.login = login;
		this.password = password;
	}

	public User(String nom, String email, String login, String password,
			Role role) {
		super();

		this.nom = nom;
		this.email = email;
		this.login = login;
		this.password = password;
		this.role = role;
		List<User> u = new ArrayList<User>();
		u.add(this);
		role.setUser(u);
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;

	}

	public List<Site> getSites() {
		return sites;
	}

	public void setSites(List<Site> sites) {
		this.sites = sites;
	}

}
